import axios from '../utils/axios'
import { ref } from 'vue'

// 外网
// const baseUrl = `http://219.233.18.244:8008/`
// 内网
const baseUrl = `http://10.214.10.32:8000/`

// 城市之声(今日,本周)
export const getRegion = async (id) => {
    let url = `${baseUrl}api-citysigns/case/getRegion?id=${id}`

    let list = 0
    const { data } = await axios.get(url)

    if (data.code == 200) {
        list = data.data
    }

    return list
}
// 城市之感(列表)
export const getSensor = async (id, pageIndex = 1, dataType = 1, address = '') => {
    let params = {
        id: id,
        address: address,
        pageIndex: pageIndex,
        pageSize: 6,
        dataType: dataType
    }
    let url = `${baseUrl}api-citysigns/case/getSensor`

    let list = 0
    const { data } = await axios.post(url, params)

    if (data.code == 200) {
        list = data.data
    }

    return list
}

// 运行状态
export const getRunState = async () => {
    let url = `${baseUrl}api-citysigns/runState/getRunState`

    let state = 0
    const { data } = await axios.get(url)

    if (data.code == 200) {
        state = data.data[0].describe
    }

    return state
}

// 获得今天体征项目的数据接口
export const getCitySignNumber = async () => {
    let url = `${baseUrl}api-citysigns/citySign/getCitySignNumber`
    const { data } = await axios.get(url)
    let num = 0

    if (data.code == 200) {
        num = data.data
    }

    return num
}

// 请求获得对应左侧的二级所有的菜单栏
export const getHomePageCitySign = async () => {
    let url = `${baseUrl}api-citysigns/citySign/getHomePageCitySign`
    const { data } = await axios.get(url)
    let list = []

    if (data.code == 200) {
        list = data.data
    }

    return list
}

// 请求获得对应左侧的二级所有的菜单栏
export const getCitySign = async (type) => {
    let url = `${baseUrl}api-citysigns/citySign/getCitySign?type=${type}`
    const { data } = await axios.get(url)
    let list = []

    if (data.code == 200) {
        list = data.data
    }

    return list
}

// 获得各类案件个数
export const getCaseNumberByType = async () => {
    let url = `${baseUrl}api-citysigns/case/getCaseNumberByType`
    const { data } = await axios.get(url)
    let list = []

    if (data.code == 200) {
        list = data.data
    }

    return list
}

// 获得对应的案件列表
export const getCaseList = async () => {
    let url = `${baseUrl}api-citysigns/case/getCaseList`
    const { data } = await axios.get(url)
    let list = []

    if (data.code == 200) {
        list = data.data
    }

    return list
}
